package it.unibo.refolding.pico;

import it.unibo.refolding.common.Sleeper;

import java.util.Objects;

public class NanoDriverSleeper implements Sleeper {

  private final NanoDriver nanoDriver;

  public NanoDriverSleeper(NanoDriver nanoDriver) {
    this.nanoDriver = Objects.requireNonNull(nanoDriver, "nanoDriver cannot be null");
  }

  @Override
  public void sleep(long millis) throws InterruptedException {
    nanoDriver.sleep(millis / 1e3);
  }

  @Override
  public void sleep(long millis, int nanos) throws InterruptedException {
    nanoDriver.sleep(millis / 1e3 + nanos / 1e9);
  }
}
